#ifndef __EPOLLEVENT__
#define __EPOLLEVENT__
#include <vector>
#include"Tcpconneciton.h"
#include "Acceptor.h"
#include<map>
using std::map;
using std::vector;

class Epollevent{

public:
    Epollevent(Acceptor &);
    void Loop();
    void unLoop();
    void addEpollreadfd(int fd);
    void deleEpollwritefd(int fd);
private:
    void waitEpollFd();
    void setNewConneciton(TcpConnectionCallback _cb);
    void setNewMessage(TcpConnectionCallback _cb);
    void setNewClose(TcpConnectionCallback _cb);
    void handlNewConnection();
    void handlNewMessage(int fd);
    void handlNeclose();
    int createEpollFd();
private:
    int _epfd;
    bool _isLooping;
    Acceptor & _accept;
    vector<struct epoll_event> _evtlist;//存放满足条件的文件描述符集合
    map<int,shared_ptr<Tcpconnection>> _cons;

    //回调函数
    TcpConnectionCallback _onNewConnection;
    TcpConnectionCallback _onNewMessage;
    TcpConnectionCallback _onNewClose;    
};




#endif